package com.qf.service.impl;

import com.qf.dao.FlowerMapper;
import com.qf.pojo.resp.BaseResp;
import com.qf.pojo.vo.StoreInfoVo;
import com.qf.service.MarketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
@Service
public class MarketServiceImpl implements MarketService {

    @Autowired
    FlowerMapper flowerMapper;
    @Override
    public BaseResp findByFree(String freeName) {
        List<StoreInfoVo> allFlower = flowerMapper.findAllFlower(2);
        List<StoreInfoVo> list = new ArrayList<StoreInfoVo>();

        for (StoreInfoVo storeInfoVo : allFlower) {
            if (storeInfoVo.getStoreDiscount().equals(freeName)){
                list.add(storeInfoVo);
            }
        }

        if (list!=null){
            //System.out.println(list);
            return new BaseResp(200, "success", list);
        }

        return new BaseResp().ERROR();
    }
}
